package impl

type QuantAccountDaoImpl struct {
	*BaseDaoImpl
}

// 返回dao实现类
func GetQuantAccountDaoImpl() *QuantAccountDaoImpl {
	return &QuantAccountDaoImpl{GetBaseDaoImpl()}
}

// 返回表名
func (_quantAccountDaoImpl *QuantAccountDaoImpl) FindTableName() string {
	return "QUANT_ACCOUNT"
}

// 清空表
func (_quantAccountDaoImpl *QuantAccountDaoImpl) TruncateTable() {
	_quantAccountDaoImpl.db.Exec("truncate table quant_account")
}

// 根据日期，从quant_account_log表中向quant_account表中插入记录
func (_quantAccountDaoImpl *QuantAccountDaoImpl) InsertFromQuantAccountLogByDate(date string) {
	_quantAccountDaoImpl.db.Exec("insert into quant_account(account_name, hold_stock_number, stock_assets, capital_assets, total_assets, total_stamp_duty, total_registrate_fee_when_buy, total_commission_when_buy, total_registrate_fee_when_sell, total_commission_when_sell) "+
		"select account_name, hold_stock_number, stock_assets, capital_assets, total_assets, total_stamp_duty, total_registrate_fee_when_buy, total_commission_when_buy, total_registrate_fee_when_sell, total_commission_when_sell "+
		"from quant_account_log where date_=to_date(?,'yyyy-mm-dd')", date)
}
